//
//  MainTabBarController.m
//  Cd_Qb
//
//  Created by rimi on 2017/4/12.
//  Copyright © 2017年 rimi. All rights reserved.
//

#import "Qb_MainTabBarController.h"
#import "Qb_ColletViewController.h"
#import "Qb_ServiceViewController.h"
#import "Qb_PushViewController.h"
#import "Qb_MessageViewController.h"
#import "Qb_MineViewController.h"


@interface Qb_MainTabBarController ()

@end

@implementation Qb_MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    NSArray *viewControllers = @[Storyboard(@"Collet", @"ColletViewController"),Storyboard(@"Message", @"Qb_MessageViewController"),Storyboard(@"Push", @"PushViewController"),Storyboard(@"Message", @"MessageViewController"),Storyboard(@"Mine", @"Qb_MineViewController")];
    
    NSArray *viewControllers = @[Storyboard(@"Collet", @"Qb_ColletViewController"),Storyboard(@"Service", @"Qb_ServiceViewController"),Storyboard(@"Push", @"Qb_PushViewController"),Storyboard(@"Message", @"Qb_MessageViewController"),Storyboard(@"Mine", @"Qb_MineViewController")];
    
    NSArray *tabBarItemTitle = @[@"收款",@"服务",@"推广",@"消息",@"我的"];
    
    NSArray *tabBarItemImage = @[[UIImage imageNamed:@"Qb_Public_Collet_Note"],[UIImage imageNamed:@"Qb_Public_Service_Note"],[UIImage imageNamed:@"Qb_Public_Push_Note"],[UIImage imageNamed:@"Qb_Public_Message_Note"],[UIImage imageNamed:@"Qb_Public_Mine_Note"]];
    
    NSArray *tabBarItemSelectedImage = @[[UIImage imageNamed:@"Qb_Public_Collet_Selected"],[UIImage imageNamed:@"Qb_Public_Service_Selected"],[UIImage imageNamed:@"Qb_Public_Push_Selected"],[UIImage imageNamed:@"Qb_Public_Message_Selected"],[UIImage imageNamed:@"Qb_Public_Mine_Selected"]];
    
    NSMutableArray * VCArray = [NSMutableArray array];
    
    for (int i = 0; i<viewControllers.count; i++) {
        UIViewController * vc = viewControllers[i];
        UITabBarItem * item = [[UITabBarItem alloc] initWithTitle:nil image:[tabBarItemImage[i] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[tabBarItemSelectedImage[i] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        //改变图片和文字的距离就打开
//        CGFloat offset = 5.0*AAdaptionWidth();
//        item.imageInsets = UIEdgeInsetsMake(offset, 0, -offset, 0);
//        item.titlePositionAdjustment = UIOffsetMake(0, 3*offset);
        vc.tabBarItem = item;
        [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:kColorRGB(169,169,169,1)} forState:UIControlStateNormal];
        [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:kColorRGB(13,128,239,1)} forState:UIControlStateSelected];
        vc.title = tabBarItemTitle[i];
        UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:vc];
        nav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
        nav.navigationBar.barTintColor = kColorRGB(0,128,255,0.7);
        nav.navigationBar.tintColor = [UIColor whiteColor];
        nav.view.backgroundColor = [UIColor whiteColor];
        [VCArray addObject:nav];
    }
    //设置tabbar颜色必须关闭透明
    self.tabBar.translucent = NO;
    self.tabBar.barTintColor = [UIColor whiteColor];
    self.viewControllers = VCArray;
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}


@end
